var comet = {
    connection: false,
    iframediv: false,
    timeoutid: -1,
    initialize: function() {
        var a = "../../cgi-bin/real?type=gps&u=" + g_uin;
        if (navigator.appVersion.indexOf("MSIE") != -1) {
            comet.connection = new ActiveXObject("htmlfile");
            comet.connection.open();
            comet.connection.write("<html>");
            comet.connection.write("<script>document.domain = '" + document.domain + "'");
            comet.connection.write("</html>");
            comet.connection.close();
            comet.iframediv = comet.connection.createElement("div");
            comet.connection.appendChild(comet.iframediv);
            comet.connection.parentWindow.comet = comet;
            comet.iframediv.innerHTML = "<iframe id='comet_iframe' src='" + a + "'></iframe>"
        } else if (navigator.appVersion.indexOf("KHTML") != -1) {
            comet.connection = document.createElement('iframe');
            comet.connection.setAttribute('id', 'comet_iframe');
            comet.connection.setAttribute('src', a);
            with(comet.connection.style) {
                position = "absolute";
                left = top = "-100px";
                height = width = "1px";
                visibility = "hidden"
            }
            document.body.appendChild(comet.connection)
        } else {
            comet.connection = document.createElement('iframe');
            comet.connection.setAttribute('id', 'comet_iframe');
            with(comet.connection.style) {
                left = top = "-100px";
                height = width = "1px";
                visibility = "hidden";
                display = 'none'
            }
            comet.iframediv = document.createElement('iframe');
            comet.iframediv.setAttribute('src', a);
            comet.connection.appendChild(comet.iframediv);
            document.body.appendChild(comet.connection)
        }
        comet.safeReset()
    },
    safeReset: function() {
        if (comet.timeoutid != -1) {
            clearTimeout(comet.timeoutid)
        }
        comet.timeoutid = setTimeout(function() {
            comet.uninit();
            comet.onUnload();
            comet.initialize()
        },
        1000 * 60 * 5)
    },
    f: function(a) {
        onDataCome(a);
        comet.safeReset()
    },
    e: function(a) {
        alert(a)
    },
    redirect: function(a) {
        window.location.href = a
    },
    uninit: function() {
        comet.iframediv.innerHTML = "";
        comet.connection = false
    },
    onUnload: function() {
        if (comet.connection) {
            comet.uninit()
        }
    }
}